// Drummer
// by Andrea Bianchi
// andreabianchi.alsoplantsfly.com

/*
 Copyright (C) 2009, Andrea Bianchi
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#include "ScreenManager.h"
// picturs for backgrounds (the order of inclusion is important)
#include "images/all_gfx.c" 
#include "images/all_gfx.h" 

using namespace DS;

ScreenManager* ScreenManager::getInstance()
{	
	static ScreenManager histnace;
	return &histnace;
}

	
void ScreenManager::init()
{
	// Drawing mode init
	PA_Init16bitBg(UPPER_SCREEN, GRAPHICS_LAYER);
	PA_Init16bitDblBuffer(LOWER_SCREEN, GRAPHICS_LAYER); 

	// clean up
	PA_ClearTextBg(UPPER_SCREEN); 
	PA_ClearTextBg(LOWER_SCREEN); 

}

void ScreenManager::draw ()
{
	switch(bg_)
	{
		case TITLE: 
			PA_Load16bitBitmap(UPPER_SCREEN, bg01_top_Bitmap);
			PA_Load16bitBitmap(LOWER_SCREEN, bg01_bot_Bitmap);
			break;

		case HIHAT: 
			PA_Load16bitBitmap(UPPER_SCREEN, bg02_top_Bitmap);
			PA_Load16bitBitmap(LOWER_SCREEN, bg02_bot_Bitmap);
			break;

		case TOM: 
			PA_Load16bitBitmap(UPPER_SCREEN, bg06_top_Bitmap);
			PA_Load16bitBitmap(LOWER_SCREEN, bg06_bot_Bitmap);
			break;

		case SNARE: 
			PA_Load16bitBitmap(UPPER_SCREEN, bg05_top_Bitmap);
			PA_Load16bitBitmap(LOWER_SCREEN, bg05_bot_Bitmap);
			break;

		case CRASH: 
			PA_Load16bitBitmap(UPPER_SCREEN, bg04_top_Bitmap);
			PA_Load16bitBitmap(LOWER_SCREEN, bg04_bot_Bitmap);
			break;

		case BASSDRUM: 
			PA_Load16bitBitmap(UPPER_SCREEN, bg03_top_Bitmap);
			PA_Load16bitBitmap(LOWER_SCREEN, bg03_bot_Bitmap);
			break;

		case IDLE: 
			PA_Load16bitBitmap(UPPER_SCREEN, bg08_top_Bitmap);
			PA_Load16bitBitmap(LOWER_SCREEN, bg08_bot_Bitmap);
			break;
			
		case HIT: 
			PA_Load16bitBitmap(UPPER_SCREEN, bg07_top_Bitmap);
			PA_Load16bitBitmap(LOWER_SCREEN, bg07_bot_Bitmap);
			break;
			
		default: break;
	}
}

void ScreenManager::finalizeDraw()
{
	PA_16bitSwapBuffer(LOWER_SCREEN);
	PA_Clear16bitBg(LOWER_SCREEN);	
}


